<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>总成绩表</title>

		<link href="../bootstrap-3.3.7-dist/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">
		<link rel="stylesheet" href="../layui/css/layui.css" media="all" />
		<style type="text/css">
			* {
				margin: 0;
				padding: 0;
			}
			
			.class_div_scorelist {
				width: 100%;
				height: 100vh;
			}
			
			.class_div_header {
				height: 15vh;
				background-image: url(../img/header.png);
				background-repeat: no-repeat;
				background-size: 100%;
			}
			
			.class_h1_header_title {
				margin: 0;
				text-align: center;
				color: #FFFFFF;
				line-height: 7vh;
			}
			
			.class_div_title {
				font-weight: bold;
				font-size: 1.3em;
			}
			
			.class_div_table {
				margin-top: 20px;
			}
			
			.td_content {
				text-align: center;
			}
			
			.tr_btngroup {
				text-align: center;
			}
			
			.tr_btngroup button {
				margin-left: 5px;
			}
			
			.class_div_btn_sub {
				float: right;
			}
			
			.class_div_logout{
				position: fixed;
				bottom:50px;
				right: 50px;
			}
			.class_div_logout button{
				width: 80px;
				height:40px;
			}
			#demo{
				width: 100%;
			}
		</style>
	</head>

	<body>
		<div class="class_div_scorelist">
			<div class="class_div_header">
			</div>
			<div class="row class_div_container" style="margin:0px">
				<div class="col-xs-10 col-xs-offset-1">
					<div class="class_div_table">
						<div class="container">
							<span class="class_div_title">
								总成绩
							</span>
							<span class="class_div_btn_sub">
								<button type="button" class="btn btn-danger" onclick="exportExcel()">导出Excel</button>
							</span>
							<table id="demo" lay-filter="test"></table>
						</div>
					</div>
				</div>
			</div>
			<div class="class_div_logout">
				<a href="Router.html"><button type="button" class="btn btn-info">返回首页</button></a>
			</div>
		</div>
		<script src="../js/jquery-1.12.4/jquery.min.js"></script>
		<script src="../bootstrap-3.3.7-dist/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
		<script src="../js/jquery-2.1.4/jquery.min.js"></script>
		<script type="text/javascript" src="../layui/layui.js"></script>
		<script type="text/javascript" src="../js/ip.js"></script>
		<script type="text/javascript">
			var headerList = [{
				field: 'index',
				title: '序号',
				type: 'numbers',
				width: '5%',
				align: 'center',
			}, {
				field: 'name',
				title: '姓名',
				align: 'center',
			}, {
				field: 'initialScore1',
				title: '一阶段得分',
				align: 'center',
				sort: true,
				templet:function(d){
					if(d.initialScore1>=0){
						return d.initialScore1;
					}else{
						return '未打分';
					}
				}
			}, {
				field: 'initialScore2',
				title: '二阶段得分',
				align: 'center',
				sort: true,
				templet:function(d){
					if(d.initialScore2>=0){
						return d.initialScore2;
					}else{
						return '未打分';
					}
				}
			}, {
				field: 'stageScore1',
				title: '理论宣讲',
				align: 'center',
				sort: true,
				templet:function(d){
					
					if(d.stageScore1>=0){
						return d.stageScore1;
					}else{
						return '未打分';
					}
				}
			}, {
				field: 'stageScore2',
				title: '谈心谈话',
				align: 'center',
				sort: true,
				templet:function(d){
					if( d.stageScore2>=0){
						return d.stageScore2;
					}else{
						return '未打分';
					}
				}
			},{
				field: 'totalScore',
				title: '总得分',
				align: 'center',
				sort: true,
				templet:function(d){
					console.log(d);
					if(d.totalScore >= 0){
						return d.totalScore;
					}else{
						return '未打分';
					}
				}
			},{
				field: 'ranking',
				title: '排名',
				align: 'center',
				sort: true,
			}]

			$(document).ready(function() {
				getTotalScoreList();
			});

			function getTotalScoreList() {
				const postaddress = ip + '/admin/grade/allgrade';
				let info = new Object();
				info.scoreInfoId = 1;
				$.ajax({
					//几个参数需要注意一下
					type: "POST", //方法类型
					dataType: "json", //预期服务器返回的数据类型
					contentType: "application/json;charset=utf-8",
					url: postaddress, //url
					data: JSON.stringify(info),
					success: function(result) {
						if(result.code === 0) {
							createTable(result.data);
						}
					},
					error: function() {

					}
				});
			}

			function createTable(tableData) {
				layui.use('table', function() {
					var table = layui.table;
					table.render({
						elem: '#demo',
						data: tableData,
						limit:100,
						cols: [headerList],
					});
				});
			}

			function exportExcel() {
				location.href = ip + '/admin/grade/allexcel?scoreInfoId=1';
			}
		</script>
	</body>

</html>